import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:lib_core/lib_core.dart';
import 'package:lib_ui/common/theme/app_theme_colors.dart';
import 'package:lib_ui/common/theme/theme_controller.dart';

import '../gen/assets.gen.dart';
import '../gen/colors.gen.dart';

class TransparentAppBar extends AppBar {
  TransparentAppBar({
    Key? key,
    String title = '',
    TextStyle titleStyle = const TextStyle(
      color: ColorName.textPrimary,
      fontSize: 18,
      fontWeight: FontWeight.bold,
    ),
    Widget? leading,
    double? leadingWidth,
    // 是否自动显示左侧的leading
    bool automaticallyImplyLeading = true,
    // 右侧widget
    List<Widget>? actions,
    // appBar的bottomBar
    Widget? bottom,
    double bottomHeight = 40,
    Color backgroundColor = Colors.transparent,
    double elevation = 0,
    // 样式设置
    SystemUiOverlayStyle systemOverlayStyle = SystemUiOverlayStyle.dark,
  }) : super(
          key: key,
          title: Text(title),
          centerTitle: true,
          // titleTextStyle: titleStyle,
          automaticallyImplyLeading: automaticallyImplyLeading,
          leading: automaticallyImplyLeading
              ? (leading ??
                  GetBuilder<ThemeController>(builder: (controller) {
                    return IconButton(
                      onPressed: () => BoostNavigator.instance.pop(),
                      icon: UIAssets.images.icArrowBack.svg(width: 32, height: 32,colorFilter: ColorFilter.mode(controller.currentTheme.iconTheme.color!, BlendMode.srcIn)
                    ));
                  }))
              : null,
          actions: actions,
          // backgroundColor: backgroundColor,
          // elevation: elevation,
          // systemOverlayStyle: systemOverlayStyle,
          bottom: bottom != null
              ? (bottom is PreferredSizeWidget)
                  ? bottom
                  : PreferredSize(preferredSize: Size.fromHeight(bottomHeight), child: bottom)
              : null,
        );
}
